﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Web;

namespace IPlugin
{
    public class RequestPostVariables
    {
        public string FullParameters { get; private set; }
        public Dictionary<string, string> ParameterList { get; private set; }

        public RequestPostVariables(string url)
        {
            FullParameters = url;
            ParameterList = new Dictionary<string, string>();
            string[] parameters = FullParameters.Split('&');

            foreach (string p in parameters)
            {
                string[] paramStr = p.Split('=');

                if (paramStr.Length == 1)
                {
                    //Parameter ohne value id
                    ParameterList[HttpUtility.UrlDecode(paramStr[0], Encoding.GetEncoding(1252))] = "";
                }
                else if (paramStr.Length == 2)
                {
                    //Parameter mit value id=1337
                    ParameterList[HttpUtility.UrlDecode(paramStr[0], Encoding.GetEncoding(1252))] = HttpUtility.UrlDecode(paramStr[1], Encoding.GetEncoding(1252));
                }
            }

        }
    }
}
